﻿@{
    string guid = Html.Guid();
    CurrentUser user = ViewBag.CurrentUser;
}
<script src="~/Incs/UEditor/ueditor.forAdmin.config.js" type="text/javascript"></script>
<script src="~/Incs/UEditor/ueditor.all.min.js" type="text/javascript"></script>
<div class="main">
    <form class="form" method="post" id="_form" data-source="@Model" data-validate-params="tipsStyle:1,beforeSubmit:'BeforeSubmit'">
        <div class="form-group">
            <label class="control-label">标签</label>
            <div class="controls">
                <input type="text" value="" class="form-control" id="Name" name="Name" data-validate="dataType:'*',nullMsg:'请填写标签!'" />
                <span class="help-block"></span>
            </div>
        </div>
        @{
        string beforeSubmitJs = "";
        var fieldData = Html.GetFieldList("pa_tag", "Add", user);
        var data = new ViewDataDictionary();
        data = new ViewDataDictionary();
        data.Add("from", "admin");
        data.Add("guid", guid);
        data.Add("currentUser", user);
        data.Add("i", 0);
        int i = 0;
        if (fieldData != null)
        {
            foreach (var row in fieldData)
            {
                data["i"] = i;
                beforeSubmitJs += row.BeforeSubmitJs;
                Html.RenderPartial("~/Areas/E/Views/CustomForm/FormPartial.cshtml", (object)row, data);
                i++;
            }
        }
        }
        <div class="submit-footerbar">
            <label class="control-label"></label>
                <div class="controls">
                    <input type="hidden" id="Id" name="Id" />
                    <input type="hidden" id="Count" name="Count" />
                    <input type="hidden" id="TableId" name="TableId" value="@ViewBag.TableId" />
                    <input type="hidden" id="Guid" name="Guid" value="@guid" />
                    <button type="button" class="btn btn-primary ui-pagePost" data-custom-params="url:'@Url.ActionUrl()',callBack:'CallBack'" id="bt_submit">提交</button>
                    <button type="button" class="btn btn-default ui-closeDialog">关闭</button>
                    <span class="help-block"></span>
                </div>
            </div>
    </form>

</div>

<script type="text/javascript">
    var $name = $("#Name");
    function BeforeSubmit()
    {
        var tag = $name.val();
        $name.val(tag.Trim());
        @Html.Raw(beforeSubmitJs)
        return true;
    }
    var id = Request("id");
    if (id != "") {
        $("#_form").FormBind({ dataSourceFrom: "attr" });
    }
    function CallBack()
    {
        PostRefreshBack();
    }
</script>
